<template>
	<view class="container">
		<view v-if="news">
			<view class="title">{{ news.title }}</view>
			<view class="meta">
				<view>{{ formatTimeTwo(new Date(news.createTime), 'Y年M月D日 h:m') }}</view>
				<view>{{ news.hit }} 阅读</view>
			</view>
			<view class="news-content">
				 <rich-text :nodes="news.description"></rich-text>
			</view>
		</view>
	</view>
</template>

<script>
	import {getNewsDetail} from '../../api/news.js'
	import {imageUrl, formatTimeTwo} from '../../utils/util.js'
	
	export default {
		data() {
			return {
				news: null
			};
		},
		onLoad(e) {
			getNewsDetail(e.id).then(result=>{
				let news = result.data
				let jsonDa = JSON.stringify(news.description).replace(/<img/gi, "<img class='richImg'style='height:auto!important;max-height:100%;width:100%;'");
				news.description = JSON.parse(jsonDa);
				this.setData({news})
			})
		},
		methods: {
			formatTimeTwo
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		.title {
			font-size: 44rpx;
			margin-top: 30rpx;
			padding: 0 20rpx;
			
		}
		.meta {
			color: #8e96a9;
			display: flex;
			flex-direction: row;
			margin: 26rpx 0;
			padding: 0 20rpx;
			font-size: 24rpx;
			view {
				margin-right: 15rpx;
			}
		}
		.news-content {
			font-size: 34rpx;
			line-height: 56rpx;
			padding: 0 20rpx;
			letter-spacing: 0.08rpx;
			word-break: normal;
			word-wrap: break-word;
		}
	}
</style>
